/* N8N Chat 自定义样式 - 现代易用美观设计 */
/* 基于现代设计原则，注重用户体验和视觉美感 */

/* 全局CSS变量定义 - 现代设计系统 */
html, body, :root {
  /* 主色调 - 现代蓝色系 */
  --chat--color--primary: #3b82f6 !important;
  --chat--color--primary-shade-50: #2563eb !important;
  --chat--color--primary--shade-100: #1d4ed8 !important;
  --chat--color--primary-light: #dbeafe !important;
  
  /* 辅助色 - 现代紫色系 */
  --chat--color--secondary: #8b5cf6 !important;
  --chat--color-secondary-shade-50: #7c3aed !important;
  --chat--color-secondary-light: #ede9fe !important;
  
  /* 基础颜色 - 现代中性色 */
  --chat--color-white: #ffffff !important;
  --chat--color-light: #f8fafc !important;
  --chat--color-light-shade-50: #f1f5f9 !important;
  --chat--color-light-shade-100: #e2e8f0 !important;
  --chat--color-medium: #cbd5e1 !important;
  --chat--color-dark: #1e293b !important;
  --chat--color-disabled: #94a3b8 !important;
  --chat--color-typing: #64748b !important;
  
  /* 功能按钮颜色 */
  --chat--color-function: #f59e0b !important;
  --chat--color-function-hover: #d97706 !important;
  --chat--color-function-light: #fef3c7 !important;

  /* 间距和圆角 - 现代设计 */
  --chat--spacing: 1rem;
  --chat--border-radius: 1rem;
  --chat--border-radius-sm: 0.75rem;
  --chat--border-radius-lg: 1.25rem;
  --chat--transition-duration: 0.3s;
  --chat--transition-easing: cubic-bezier(0.4, 0, 0.2, 1);

  /* 阴影系统 */
  --chat--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --chat--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --chat--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --chat--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* 窗口尺寸 */
  --chat--window--width: 100%;
  --chat--window--height: 100%;
  --chat--window--min-height: 600px;

  /* 头部样式 */
  --chat--header-height: auto;
  --chat--header--padding: 1.5rem;
  --chat--header--background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --chat--header--color: var(--chat--color-white);
  --chat--heading--font-size: 1.25rem;
  --chat--heading--font-weight: 600;
  --chat--subtitle--font-size: 0.875rem;
  --chat--subtitle--line-height: 1.4;
  --chat--subtitle--opacity: 0.9;

  /* 输入框样式 */
  --chat--textarea--height: 60px;
  --chat--textarea--background: var(--chat--color-white);
  --chat--textarea--border: 2px solid var(--chat--color-light-shade-100);
  --chat--textarea--border-radius: var(--chat--border-radius-lg);
  --chat--textarea--padding: 1rem 1.25rem;
  --chat--textarea--font-size: 0.875rem;
  --chat--textarea--focus--border-color: var(--chat--color--primary);
  --chat--textarea--focus--box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);

  /* 消息样式 */
  --chat--message--font-size: 0.875rem;
  --chat--message--padding: 1rem 1.25rem;
  --chat--message--border-radius: var(--chat--border-radius-lg);
  --chat--message-line-height: 1.6;
  --chat--message--margin-bottom: 0.75rem;
  
  /* 机器人消息 */
  --chat--message--bot--background: var(--chat--color-white);
  --chat--message--bot--color: var(--chat--color-dark);
  --chat--message--bot--border: 1px solid var(--chat--color-light-shade-100);
  --chat--message--bot--box-shadow: var(--chat--shadow-md);
  
  /* 用户消息 */
  --chat--message--user--background: linear-gradient(135deg, var(--chat--color--primary) 0%, var(--chat--color--primary-shade-50) 100%);
  --chat--message--user--color: var(--chat--color-white);
  --chat--message--user--border: none;
  --chat--message--user--box-shadow: var(--chat--shadow-lg);

  /* 动画效果 */
  --chat--animation--duration: 0.3s;
  --chat--animation--easing: var(--chat--transition-easing);
}

/* 直接覆盖N8N Chat样式 - 现代设计 */
.n8n-chat, 
.n8n-chat *,
[class*="n8n-chat"],
[class*="chat-"] {
  /* 强制应用自定义样式 */
  --chat--color--primary: #3b82f6 !important;
  --chat--color--primary-shade-50: #2563eb !important;
  --chat--color--primary--shade-100: #1d4ed8 !important;
  --chat--color--secondary: #8b5cf6 !important;
  --chat--color-white: #ffffff !important;
  --chat--color-light: #f8fafc !important;
  --chat--color-dark: #1e293b !important;
  --chat--border-radius: 1rem !important;
  --chat--spacing: 1rem !important;
}

/* 聊天容器整体样式 - 现代设计 */
.n8n-chat {
  width: 100% !important;
  height: 800px !important;
  min-height: 800px !important;
  max-height: 800px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  position: relative !important;
  border-radius: var(--chat--border-radius-lg) !important;
  background: var(--chat--color-white) !important;
  box-shadow: var(--chat--shadow-xl) !important;
  border: 1px solid var(--chat--color-light-shade-100) !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* 头部样式 - 现代渐变设计 */
.n8n-chat .chat-header,
.n8n-chat [class*="header"] {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: var(--chat--color-white) !important;
  border-radius: var(--chat--border-radius-lg) var(--chat--border-radius-lg) 0 0 !important;
  padding: 2rem !important;
  position: relative !important;
  z-index: 1 !important;
  border: none !important;
  box-shadow: var(--chat--shadow-lg) !important;
  flex-shrink: 0 !important;
  min-height: 100px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;
  overflow: hidden !important;
  text-align: center !important;
}

/* 头部装饰性背景 */
.n8n-chat .chat-header::before {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>') !important;
  opacity: 0.3 !important;
}

.n8n-chat .chat-header-content {
  position: relative !important;
  z-index: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;
  width: 100% !important;
  text-align: center !important;
}

.n8n-chat .chat-avatar {
  display: none !important;
}

.n8n-chat .chat-title {
  flex: 1 !important;
  text-align: center !important;
}

.n8n-chat .chat-title h3 {
  display: none !important;
}

.n8n-chat .chat-title p {
  font-size: 1rem !important;
  font-weight: 500 !important;
  margin: 0 !important;
  line-height: 1.4 !important;
  color: rgba(255, 255, 255, 0.9) !important;
  text-align: center !important;
  letter-spacing: 0.025em !important;
}

/* 头部描述文本样式 */
.n8n-chat .chat-header-description {
  font-size: 1rem !important;
  font-weight: 500 !important;
  color: rgba(255, 255, 255, 0.9) !important;
  text-align: center !important;
  margin: 0 !important;
  line-height: 1.4 !important;
  letter-spacing: 0.025em !important;
}

/* 消息区域样式 - 现代设计 */
.n8n-chat .chat-messages,
.n8n-chat [class*="messages"] {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
  border-radius: 0 !important;
  flex: 1 !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  padding: 2rem !important;
  border: none !important;
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 1.25rem !important;
}

/* 消息区域装饰性边框 */
.n8n-chat .chat-messages::before {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 1px !important;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent) !important;
}

/* 欢迎消息样式 - 现代卡片设计 */
.n8n-chat .welcome-message {
  background: var(--chat--color-white) !important;
  border-radius: var(--chat--border-radius-lg) !important;
  padding: 2rem !important;
  box-shadow: var(--chat--shadow-lg) !important;
  border: 1px solid var(--chat--color-light-shade-100) !important;
  position: relative !important;
  overflow: hidden !important;
  margin-bottom: 1.5rem !important;
  text-align: center !important;
}

.n8n-chat .welcome-message::before {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 4px !important;
  height: 100% !important;
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
}

.n8n-chat .welcome-message h4 {
  color: var(--chat--color-dark) !important;
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  margin: 0 0 1rem 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.5rem !important;
}

.n8n-chat .welcome-message p {
  color: var(--chat--color-typing) !important;
  font-size: 0.875rem !important;
  line-height: 1.6 !important;
  margin: 0 0 1rem 0 !important;
}

.n8n-chat .welcome-message p:last-child {
  margin-bottom: 0 !important;
}

/* 预制提示词按钮区域 - 现代网格设计 */
.n8n-chat .preset-prompts {
  margin-top: 1.5rem !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 1rem !important;
}

.n8n-chat .preset-prompt-btn {
  background: var(--chat--color-white) !important;
  border: 2px solid var(--chat--color-light-shade-100) !important;
  border-radius: var(--chat--border-radius) !important;
  padding: 1.25rem 1.5rem !important;
  font-size: 0.875rem !important;
  color: var(--chat--color-dark) !important;
  cursor: pointer !important;
  transition: all var(--chat--transition-duration) var(--chat--transition-easing) !important;
  text-align: left !important;
  position: relative !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  gap: 1rem !important;
  box-shadow: var(--chat--shadow-sm) !important;
}

.n8n-chat .preset-prompt-btn::before {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: -100% !important;
  width: 100% !important;
  height: 100% !important;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent) !important;
  transition: left 0.5s ease !important;
}

.n8n-chat .preset-prompt-btn:hover {
  border-color: var(--chat--color--primary) !important;
  color: var(--chat--color--primary) !important;
  transform: translateY(-3px) !important;
  box-shadow: var(--chat--shadow-lg) !important;
}

.n8n-chat .preset-prompt-btn:hover::before {
  left: 100% !important;
}

.n8n-chat .preset-prompt-btn:active {
  transform: translateY(-1px) !important;
}

.n8n-chat .prompt-icon {
  font-size: 1.5rem !important;
  flex-shrink: 0 !important;
  color: var(--chat--color--primary) !important;
}

.n8n-chat .prompt-content {
  flex: 1 !important;
}

.n8n-chat .prompt-title {
  font-weight: 600 !important;
  color: var(--chat--color-dark) !important;
  margin-bottom: 0.25rem !important;
}

.n8n-chat .prompt-description {
  font-size: 0.75rem !important;
  color: var(--chat--color-typing) !important;
  line-height: 1.3 !important;
}

/* 消息气泡样式 - 现代设计 */
.n8n-chat .chat-message,
.n8n-chat [class*="message"] {
  margin-bottom: 0 !important;
  padding: 1.25rem 1.5rem !important;
  border-radius: var(--chat--border-radius-lg) !important;
  max-width: 85% !important;
  word-wrap: break-word !important;
  line-height: 1.6 !important;
  box-shadow: var(--chat--shadow-md) !important;
  position: relative !important;
  animation: slideInUp 0.4s var(--chat--transition-easing) !important;
  font-size: 0.875rem !important;
}

/* 消息内容文本溢出处理 - 强制换行 */
.n8n-chat .message-content,
.embedded-chat-container .message-content {
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  hyphens: auto !important;
  line-height: 1.5 !important;
  max-width: 100% !important;
  white-space: pre-wrap !important;
}

/* 代码块溢出处理 */
.n8n-chat .message-content pre,
.n8n-chat .message-content code,
.embedded-chat-container .message-content pre,
.embedded-chat-container .message-content code {
  word-break: break-all !important;
  overflow-wrap: anywhere !important;
  white-space: pre-wrap !important;
  max-width: 100% !important;
  overflow-x: auto !important;
}

/* 链接溢出处理 */
.n8n-chat .message-content a,
.embedded-chat-container .message-content a {
  word-break: break-all !important;
  overflow-wrap: anywhere !important;
  color: inherit !important;
  text-decoration: underline !important;
}

/* 确保所有文本元素都能正确换行 */
.n8n-chat .message-content *,
.embedded-chat-container .message-content * {
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  max-width: 100% !important;
  white-space: normal !important;
}

/* 生成图片样式 */
.image-prompt {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.image-prompt .text-sm {
  color: #64748b;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.image-prompt .bg-gray-50 {
  background: #f1f5f9;
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #334155;
}

.generated-image {
  margin-bottom: 1rem;
}

.generated-image .text-sm {
  color: #64748b;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.image-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.image-container img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.image-container img:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

/* 图片模态框样式 */
.image-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.3s ease-out;
}

.image-modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: white;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: scaleIn 0.3s ease-out;
}

.image-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  padding: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.image-modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.image-modal-close svg {
  width: 1.5rem;
  height: 1.5rem;
}

.image-modal-img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  display: block;
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* 机器人消息样式 - 现代设计 */
.n8n-chat .chat-message--bot,
.n8n-chat [class*="message--bot"],
.n8n-chat .chat-message--assistant,
.n8n-chat [class*="message--assistant"],
.embedded-chat-container .message--assistant,
.embedded-chat-container [class*="message--assistant"],
.embedded-chat-container .message.message--assistant {
  background: var(--chat--color-white) !important;
  border: 1px solid var(--chat--color-light-shade-100) !important;
  box-shadow: var(--chat--shadow-md) !important;
  margin-right: auto !important;
  margin-left: 0 !important;
  color: var(--chat--color-dark) !important;
  align-self: flex-start !important;
  border-radius: var(--chat--border-radius-lg) var(--chat--border-radius-lg) var(--chat--border-radius-lg) 0.5rem !important;
}

/* 强制AI消息左对齐 - 最高优先级 */
.embedded-chat-container .message-item .message--assistant {
  margin-right: auto !important;
  margin-left: 0 !important;
  align-self: flex-start !important;
  background: var(--chat--color-white) !important;
  border: 1px solid var(--chat--color-light-shade-100) !important;
  color: var(--chat--color-dark) !important;
}

/* 确保AI消息容器左对齐 */
.embedded-chat-container .message-item:has(.message--assistant) {
  justify-content: flex-start !important;
}

/* 确保用户消息容器右对齐 */
.embedded-chat-container .message-item:has(.message--user) {
  justify-content: flex-end !important;
}

/* 用户消息样式 - 现代渐变设计 */
.n8n-chat .chat-message--user,
.n8n-chat [class*="message--user"],
.embedded-chat-container .message--user,
.embedded-chat-container [class*="message--user"],
.embedded-chat-container .message.message--user {
  background: linear-gradient(135deg, var(--chat--color--primary) 0%, var(--chat--color--primary-shade-50) 100%) !important;
  color: var(--chat--color-white) !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  box-shadow: var(--chat--shadow-lg) !important;
  border: none !important;
  align-self: flex-end !important;
  border-radius: var(--chat--border-radius-lg) var(--chat--border-radius-lg) 0.5rem var(--chat--border-radius-lg) !important;
}

/* 强制用户消息右对齐 - 最高优先级 */
.embedded-chat-container .message-item .message--user {
  margin-left: auto !important;
  margin-right: 0 !important;
  align-self: flex-end !important;
  background: linear-gradient(135deg, var(--chat--color--primary) 0%, var(--chat--color--primary-shade-50) 100%) !important;
  color: var(--chat--color-white) !important;
}

/* 输入区域整体布局 - 现代设计 */
.n8n-chat .chat-input-area,
.n8n-chat [class*="input-area"],
.n8n-chat .chat-input-container,
.n8n-chat [class*="input-container"] {
  background: var(--chat--color-white) !important;
  border-top: 1px solid var(--chat--color-light-shade-100) !important;
  padding: 2rem !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 1.5rem !important;
  flex-shrink: 0 !important;
  position: relative !important;
  z-index: 10 !important;
  min-height: 140px !important;
  border-radius: 0 0 var(--chat--border-radius-lg) var(--chat--border-radius-lg) !important;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

.n8n-chat .input-container,
.n8n-chat .chat-input-wrapper,
.n8n-chat [class*="input-wrapper"],
.n8n-chat .input-wrapper {
  display: flex !important;
  align-items: center !important;
  gap: 1rem !important;
  background: var(--chat--color-light) !important;
  border-radius: var(--chat--border-radius-lg) !important;
  padding: 1rem 1.25rem !important;
  border: 2px solid var(--chat--color-light-shade-100) !important;
  transition: all var(--chat--transition-duration) var(--chat--transition-easing) !important;
  box-shadow: var(--chat--shadow-sm) !important;
  min-height: 60px !important;
}

.n8n-chat .input-container:focus-within,
.n8n-chat .chat-input-wrapper:focus-within,
.n8n-chat [class*="input-wrapper"]:focus-within,
.n8n-chat .input-wrapper:focus-within {
  border-color: var(--chat--color--primary) !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
  background: var(--chat--color-white) !important;
  transform: translateY(-1px) !important;
}

/* 输入框样式 - 现代设计 */
.n8n-chat .chat-input,
.n8n-chat [class*="input"],
.n8n-chat textarea,
.n8n-chat input[type="text"],
.n8n-chat input[type="textarea"],
.n8n-chat .message-input,
.n8n-chat .user-input {
  border: none !important;
  background: transparent !important;
  padding: 0.75rem 0 !important;
  font-size: 0.875rem !important;
  resize: none !important;
  min-height: 24px !important;
  max-height: 120px !important;
  flex: 1 !important;
  line-height: 1.5 !important;
  outline: none !important;
  color: var(--chat--color-dark) !important;
  font-weight: 400 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.n8n-chat .chat-input::placeholder,
.n8n-chat [class*="input"]::placeholder,
.n8n-chat textarea::placeholder,
.n8n-chat input[type="text"]::placeholder,
.n8n-chat input[type="textarea"]::placeholder,
.n8n-chat .message-input::placeholder,
.n8n-chat .user-input::placeholder {
  color: var(--chat--color-disabled) !important;
  font-size: 0.875rem !important;
}

.n8n-chat .chat-input:focus,
.n8n-chat [class*="input"]:focus,
.n8n-chat textarea:focus,
.n8n-chat input[type="text"]:focus,
.n8n-chat input[type="textarea"]:focus,
.n8n-chat .message-input:focus,
.n8n-chat .user-input:focus {
  border-color: var(--chat--color--primary) !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
  outline: none !important;
  transform: none !important;
}

/* 发送按钮样式 - 现代设计 */
.n8n-chat .chat-button,
.n8n-chat [class*="button"],
.n8n-chat .send-button {
  background: linear-gradient(135deg, var(--chat--color--primary) 0%, var(--chat--color--primary-shade-50) 100%) !important;
  border-radius: var(--chat--border-radius-sm) !important;
  color: var(--chat--color-white) !important;
  border: none !important;
  box-shadow: var(--chat--shadow-md) !important;
  width: 44px !important;
  height: 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  cursor: pointer !important;
  transition: all var(--chat--transition-duration) var(--chat--transition-easing) !important;
  position: relative !important;
}

.n8n-chat .chat-button:hover,
.n8n-chat [class*="button"]:hover,
.n8n-chat .send-button:hover {
  background: linear-gradient(135deg, var(--chat--color--primary-shade-50) 0%, var(--chat--color--primary--shade-100) 100%) !important;
  transform: translateY(-2px) !important;
  box-shadow: var(--chat--shadow-lg) !important;
}

.n8n-chat .chat-button:active,
.n8n-chat [class*="button"]:active,
.n8n-chat .send-button:active {
  transform: translateY(0) !important;
  box-shadow: var(--chat--shadow-md) !important;
}

/* 功能按钮区域 - 现代网格设计 */
.n8n-chat .function-buttons {
  display: grid !important;
  grid-template-columns: repeat(7, 1fr) !important;
  gap: 1rem !important;
  margin-top: 1.5rem !important;
}

.n8n-chat .function-button {
  background: var(--chat--color-white) !important;
  border: 2px solid var(--chat--color-light-shade-100) !important;
  border-radius: var(--chat--border-radius) !important;
  padding: 1rem 0.75rem !important;
  font-size: 0.75rem !important;
  color: var(--chat--color-dark) !important;
  cursor: pointer !important;
  transition: all var(--chat--transition-duration) var(--chat--transition-easing) !important;
  text-align: center !important;
  position: relative !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 0.75rem !important;
  min-height: 90px !important;
  box-shadow: var(--chat--shadow-sm) !important;
}

.n8n-chat .function-button:hover {
  border-color: var(--chat--color-function) !important;
  color: var(--chat--color-function) !important;
  transform: translateY(-3px) !important;
  box-shadow: var(--chat--shadow-lg) !important;
}

.n8n-chat .function-button:active {
  transform: translateY(-1px) !important;
}

.n8n-chat .function-icon {
  font-size: 1.5rem !important;
  color: var(--chat--color-function) !important;
  flex-shrink: 0 !important;
}

.n8n-chat .function-text {
  font-weight: 600 !important;
  color: inherit !important;
  line-height: 1.2 !important;
}

/* 输入框禁用状态 */
.n8n-chat .chat-input:disabled,
.n8n-chat [class*="input"]:disabled,
.n8n-chat textarea:disabled {
  background: var(--chat--color-light) !important;
  color: var(--chat--color-disabled) !important;
  cursor: not-allowed !important;
}

/* 输入框自动调整高度 */
.n8n-chat textarea {
  overflow-y: auto !important;
  scrollbar-width: thin !important;
}

/* 消息动画效果 */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

/* 自定义滚动条 */
.n8n-chat ::-webkit-scrollbar {
  width: 8px !important;
}

.n8n-chat ::-webkit-scrollbar-track {
  background: var(--chat--color-light);
  border-radius: 4px;
}

.n8n-chat ::-webkit-scrollbar-thumb {
  background: var(--chat--color-medium);
  border-radius: 4px;
}

.n8n-chat ::-webkit-scrollbar-thumb:hover {
  background: var(--chat--color-dark);
}

/* 消息动画 */
.n8n-chat .chat-message {
  animation: slideInUp var(--chat--animation--duration) var(--chat--animation--easing);
}

/* 输入框焦点效果 */
.n8n-chat .chat-input:focus {
  border-color: var(--chat--textarea--focus--border-color);
  box-shadow: var(--chat--textarea--focus--box-shadow);
  outline: none;
}

/* 按钮悬停效果 */
.n8n-chat .chat-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--chat--shadow-lg);
}

/* 响应式设计 - 现代移动优先 */
@media (max-width: 768px) {
  :root {
    --chat--window--width: 100%;
    --chat--window--height: 100vh;
    --chat--window--min-height: 500px;
    --chat--spacing: 0.75rem;
    --chat--header--padding: 1rem;
    --chat--message--padding: 0.75rem;
    --chat--heading--font-size: 1rem;
    --chat--subtitle--font-size: 0.7rem;
  }
  
  /* 移动端聊天区域优化 */
  .n8n-chat .chat-messages,
  .n8n-chat [class*="messages"] {
    min-height: 400px !important;
    max-height: 600px !important;
    padding: 1.5rem 1rem !important;
  }
  
  /* 移动端输入区域优化 */
  .n8n-chat .chat-input-area,
  .n8n-chat [class*="input-area"],
  .n8n-chat .chat-input-container,
  .n8n-chat [class*="input-container"] {
    padding: 1.5rem 1rem !important;
    gap: 1rem !important;
    min-height: 120px !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .n8n-chat .chat-input,
  .n8n-chat [class*="input"],
  .n8n-chat textarea {
    min-height: 20px !important;
    max-height: 100px !important;
    font-size: 0.8rem !important;
  }
  
  .n8n-chat .chat-button,
  .n8n-chat [class*="button"],
  .n8n-chat .send-button {
    width: 40px !important;
    height: 40px !important;
  }
  
  /* 移动端功能按钮优化 */
  .n8n-chat .function-buttons {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.75rem !important;
  }
  
  .n8n-chat .function-button {
    min-height: 80px !important;
    padding: 0.75rem 0.5rem !important;
    font-size: 0.7rem !important;
  }
  
  .n8n-chat .function-icon {
    font-size: 1.25rem !important;
  }
  
  /* 移动端预制提示词优化 */
  .n8n-chat .preset-prompts {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  
  .n8n-chat .preset-prompt-btn {
    padding: 1rem !important;
  }
  
  .n8n-chat .prompt-icon {
    font-size: 1.25rem !important;
  }
}

/* 大屏幕优化 - 现代设计 */
@media (min-width: 1024px) {
  :root {
    --chat--window--min-height: 700px;
  }
  
  .n8n-chat .chat-messages,
  .n8n-chat [class*="messages"] {
    min-height: 600px !important;
    max-height: 700px !important;
  }
  
  /* 大屏幕功能按钮优化 */
  .n8n-chat .function-buttons {
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 1.25rem !important;
  }
  
  .n8n-chat .function-button {
    min-height: 100px !important;
    padding: 1.25rem 1rem !important;
  }
}

/* 深色模式支持 - 现代设计 */
@media (prefers-color-scheme: dark) {
  :root {
    --chat--color-light: #1f2937;
    --chat--color-light-shade-50: #374151;
    --chat--color-light-shade-100: #4b5563;
    --chat--color-dark: #f9fafb;
    --chat--color-medium: #6b7280;
    --chat--color-white: #111827;
    --chat--color-disabled: #9ca3af;
    --chat--color-typing: #d1d5db;
  }
}

/* 额外的视觉效果增强 - 现代设计 */
.n8n-chat .chat-message:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--chat--shadow-lg) !important;
  transition: all var(--chat--transition-duration) var(--chat--transition-easing) !important;
}

.n8n-chat .chat-message--user:hover {
  box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.3) !important;
}

/* 打字指示器样式 - 现代设计 */
.n8n-chat .typing-indicator {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  padding: 1rem 1.25rem !important;
  background: var(--chat--color-white) !important;
  border-radius: var(--chat--border-radius-lg) var(--chat--border-radius-lg) var(--chat--border-radius-lg) 0.5rem !important;
  border: 1px solid var(--chat--color-light-shade-100) !important;
  box-shadow: var(--chat--shadow-md) !important;
  max-width: 80px !important;
  margin-right: auto !important;
  margin-left: 0 !important;
}

.n8n-chat .typing-dot {
  width: 8px !important;
  height: 8px !important;
  background: var(--chat--color-disabled) !important;
  border-radius: 50% !important;
  animation: pulse 1.4s infinite ease-in-out !important;
}

.n8n-chat .typing-dot:nth-child(1) {
  animation-delay: -0.32s !important;
}

.n8n-chat .typing-dot:nth-child(2) {
  animation-delay: -0.16s !important;
}

/* 加载状态样式 - 现代设计 */
.n8n-chat .loading-message {
  background: var(--chat--color-white) !important;
  border: 1px solid var(--chat--color-light-shade-100) !important;
  border-radius: var(--chat--border-radius-lg) var(--chat--border-radius-lg) var(--chat--border-radius-lg) 0.5rem !important;
  padding: 1rem 1.25rem !important;
  box-shadow: var(--chat--shadow-md) !important;
  max-width: 120px !important;
  margin-right: auto !important;
  margin-left: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
}

.n8n-chat .loading-spinner {
  width: 16px !important;
  height: 16px !important;
  border: 2px solid var(--chat--color-light-shade-100) !important;
  border-top: 2px solid var(--chat--color--primary) !important;
  border-radius: 50% !important;
  animation: spin 1s linear infinite !important;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 错误状态样式 - 现代设计 */
.n8n-chat .error-message {
  background: #fef2f2 !important;
  border: 1px solid #fecaca !important;
  color: #dc2626 !important;
  border-radius: var(--chat--border-radius-lg) !important;
  padding: 1rem 1.25rem !important;
  box-shadow: var(--chat--shadow-md) !important;
  max-width: 80% !important;
  margin-right: auto !important;
  margin-left: 0 !important;
}

/* 成功状态样式 - 现代设计 */
.n8n-chat .success-message {
  background: #f0fdf4 !important;
  border: 1px solid #bbf7d0 !important;
  color: #16a34a !important;
  border-radius: var(--chat--border-radius-lg) !important;
  padding: 1rem 1.25rem !important;
  box-shadow: var(--chat--shadow-md) !important;
  max-width: 80% !important;
  margin-right: auto !important;
  margin-left: 0 !important;
}

/* 确保输入框显示 - 通用规则 */
.n8n-chat input,
.n8n-chat textarea,
.n8n-chat [type="text"],
.n8n-chat [type="textarea"] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
  z-index: 1 !important;
}

/* 确保输入区域显示 */
.n8n-chat [class*="input"],
.n8n-chat [class*="Input"],
.n8n-chat [class*="INPUT"] {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* 强制显示所有可能的输入相关元素 */
.n8n-chat *[class*="input"],
.n8n-chat *[class*="Input"],
.n8n-chat *[class*="INPUT"],
.n8n-chat *[class*="message"],
.n8n-chat *[class*="Message"],
.n8n-chat *[class*="MESSAGE"],
.n8n-chat *[class*="text"],
.n8n-chat *[class*="Text"],
.n8n-chat *[class*="TEXT"],
.n8n-chat *[class*="form"],
.n8n-chat *[class*="Form"],
.n8n-chat *[class*="FORM"] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* 强制显示输入容器 */
.n8n-chat *[class*="container"],
.n8n-chat *[class*="Container"],
.n8n-chat *[class*="CONTAINER"],
.n8n-chat *[class*="wrapper"],
.n8n-chat *[class*="Wrapper"],
.n8n-chat *[class*="WRAPPER"] {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* 确保底部区域显示 */
.n8n-chat *[class*="bottom"],
.n8n-chat *[class*="Bottom"],
.n8n-chat *[class*="BOTTOM"],
.n8n-chat *[class*="footer"],
.n8n-chat *[class*="Footer"],
.n8n-chat *[class*="FOOTER"] {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* 强制创建输入框 - 如果不存在 */
.n8n-chat::after {
  content: '' !important;
  display: block !important;
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 120px !important;
  background: var(--chat--color-white) !important;
  border-top: 1px solid var(--chat--color-light-shade-100) !important;
  border-radius: 0 0 var(--chat--border-radius-lg) var(--chat--border-radius-lg) !important;
  z-index: 1000 !important;
  pointer-events: none !important;
}

/* 确保输入框在底部显示 */
.n8n-chat {
  position: relative !important;
}

.n8n-chat > *:last-child {
  position: relative !important;
  z-index: 1001 !important;
  pointer-events: auto !important;
}

/* 隐藏底部的 Powered by 信息 */
.n8n-chat .chat-footer,
.n8n-chat [class*="footer"],
.n8n-chat [class*="powered"],
.n8n-chat [class*="n8n"] {
  display: none !important;
}